<?php

/**
 * Yii Controller ProductController
 *
 * @author trongkhoi
 * @since Nov 29, 2014 - 11:03:43 PM
 */
class PostController extends CrudController
{

    public $modelName = 'Post';
    public $title = 'Post';

    public function init()
    {
        parent::init();
        $this->indexColumns = array(
//            array(
//                'class' => 'CCheckBoxColumn',
//                'id' => 'ids',
//                'selectableRows' => 2,
//            ),
            array(
                'header' => Yii::t('user', 'Title'),
                'name' => 'title',
                'type' => 'raw',
                'value' => 'CHtml::link($data->title,$data->editUrl,array("target"=>"blank"))',
//                'filter' => CHtml::textField('name', getQuery('name', ''), array('placeHolder' => Yii::t('user', 'Search'))),
            ),
            array(
                'header' => Yii::t('user', 'Category'),
                'name' => 'category_id',
                'type' => 'raw',
                'value' => '$data->category_id?CHtml::link(@$data->category->name,@$data->category->editUrl,array("target"=>"blank")):""',
                'filter' => CHtml::dropDownList("category_id", getQuery('category_id', 0), Category::getPublicArray(), array(
                    "data-rel" => "chosen"
                )),
            ),
            array(
                'header' => Yii::t('user', 'Status'),
                'name' => 'status',
                'type' => 'raw',
                'value' => '$data->statusLabel',
                'filter' => false
            ),
            array('class' => 'application.widgets.MyButtonColumn',
                'editUrl' => '$data->editUrl',
                'deleteUrl' => '#',
                'htmlOptions' => array(
                    'width' => '1%'
                )
            ),
        );

        $this->formColumns = array(
            'title' => array(
                'type' => 'createUrl',
                'for' => 'url'
            ),
            'url',
            'thumbnail' => array(
                'type' => 'ckfinder',
                'alt' => 'ckfinder',
                'data' => $this->model->getPublicImg()
            ),
            'category_id' => array(
                'type' => 'dropDownList',
                'data' => Category::getPublicArray(),
            ),
            'description' => array(
                'type' => 'textArea',
            ),
            'content' => array(
                'type' => 'ckeditor',
            ),
            'status' => array(
                'type' => 'radioButtonList',
                'data' => MyActiveRecord::getArrayStatus(),
            ),
        );
    }

}

/** 
 * End file ProductController
 */
